<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<div class="x_panel">
    <div class="x_title">
        <ol class="breadcrumb pull-left">
            <li><a ng-click="navigateToPath('/profiles')">Profiles</a></li>
            <li class="active">{{profileName}}</li>
        </ol>
        <div class="pull-right" role="group" ng-show="!settings.isNew">
            <button class="btn btn-primary" title="View Parameters" ng-click="viewParams()">View Parameters</button>
            <div class="btn-group" role="group" uib-dropdown is-open="more.isopen">
                <button type="button" class="btn btn-default dropdown-toggle" uib-dropdown-toggle aria-haspopup="true" aria-expanded="false">
                    More&nbsp;
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu-right dropdown-menu" uib-dropdown-menu>
                    <li role="menuitem"><a ng-click="viewDeliveryServices()" ng-if="profile.type == 'DS_PROFILE'">View Delivery Services</a></li>
                    <li role="menuitem"><a ng-click="viewParams()">View Parameters</a></li>
                    <li role="menuitem"><a ng-click="viewServers()" ng-if="profile.type != 'DS_PROFILE'">View Servers</a></li>
                    <li class="divider"></li>
                    <li role="menuitem"><a ng-click="cloneProfile()">Clone Profile</a></li>
                    <li role="menuitem"><a ng-click="exportProfile(profile)">Export Profile</a></li>
                </ul>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <div class="x_content">
        <br>
        <form name="profileForm" class="form-horizontal form-label-left" novalidate>
            <div class="form-group" ng-class="{'has-error': hasError(profileForm.name), 'has-feedback': hasError(profileForm.name)}">
                <label class="control-label col-md-2 col-sm-2 col-xs-12">Name *</label>
                <div class="col-md-10 col-sm-10 col-xs-12">
                    <input name="name" type="text" class="form-control" ng-model="profile.name" ng-maxlength="45" ng-pattern="/^\S*$/" required autofocus>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.name, 'required')">Required</small>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.name, 'maxlength')">Too Long</small>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.name, 'pattern')">No spaces</small>
                    <span ng-show="hasError(profileForm.name)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
            <div class="form-group" ng-class="{'has-error': hasError(profileForm.cdn), 'has-feedback': hasError(profileForm.cdn)}">
                <label class="control-label col-md-2 col-sm-2 col-xs-12">CDN *</label>
                <div class="col-md-10 col-sm-10 col-xs-12">
                    <select name="cdn" class="form-control" ng-model="profile.cdn" ng-options="cdn.id as cdn.name for cdn in cdns" required>
                        <option value="">Select...</option>
                    </select>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.cdn, 'required')">Required</small>
                    <small ng-show="profile.cdn"><a href="/#!/cdns/{{profile.cdn}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
                </div>
            </div>
            <div class="form-group" ng-class="{'has-error': hasError(profileForm.type), 'has-feedback': hasError(profileForm.type)}">
                <label class="control-label col-md-2 col-sm-2 col-xs-12">Type *</label>
                <div class="col-md-10 col-sm-10 col-xs-12">
                    <select name="type" class="form-control" ng-model="profile.type" ng-options="type.value as type.value for type in types" required>
                        <option value="">Select...</option>
                    </select>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.cdn, 'required')">Required</small>
                </div>
            </div>
            <div class="form-group" ng-class="{'has-error': hasError(profileForm.routingDisabled), 'has-feedback': hasError(profileForm.routingDisabled)}">
                <label class="control-label col-md-2 col-sm-2 col-xs-12">Routing Disabled *</label>
                <div class="col-md-10 col-sm-10 col-xs-12">
                    <select name="routingDisabled" class="form-control" ng-model="profile.routingDisabled" ng-options="x.value as x.label for x in falseTrue" required>
                        <option value="">Select...</option>
                    </select>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.routingDisabled, 'required')">Required</small>
                </div>
            </div>
            <div class="form-group" ng-class="{'has-error': hasError(profileForm.description), 'has-feedback': hasError(profileForm.description)}">
                <label class="control-label col-md-2 col-sm-2 col-xs-12">Description *</label>
                <div class="col-md-10 col-sm-10 col-xs-12">
                    <textarea name="description" rows="3" cols="17" class="form-control" ng-model="profile.description" maxlength="256" required></textarea>
                    <small class="input-error" ng-show="hasPropertyError(profileForm.description, 'required')">Required</small>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(profile)">Delete</button>
                <button type="button" class="btn btn-success" ng-disabled="profileForm.$pristine || profileForm.$invalid" ng-click="save(profile)">{{settings.saveLabel}}</button>
            </div>
        </form>
    </div>
</div>
